﻿using System.ComponentModel;

namespace AppScan
{
    public partial class SummaryPage : Wizard.UI.InternalWizardPage
    {
        private readonly CreateUserContext _context;

        public SummaryPage(CreateUserContext context)
        {
            _context = context;

            InitializeComponent();
        }

        private void SummaryPage_SetActive(object sender, CancelEventArgs e)
        {
            //list targets, comma delim or mouse over event
            string targets_all = string.Empty;

            int limit = 4;
            int max =_context.targeta.Length;
            if (_context.targeta.Length> limit)
            {
                max = limit;
            }
            for (int i = 0; i < max; i++)
            {
                targets_all += _context.targeta[i];
                if (_context.targeta.Length>1)
                    targets_all += ", ";
                if (i == max - 1 && _context.targeta.Length>1)
                {
                    targets_all += ". . .";
                }
            }
            userNameLabel.Text = targets_all;
            //Using current credentials or supplied
            fullNameLabel.Text = _context.domain.ToUpper()+"\\"+_context.username;
            descriptionLabel.Text = _context.prefix;
            optionsLabel.Text = _context.AdvancedOptions;
        }

        private void SummaryPage_WizardBack(object sender, Wizard.UI.WizardPageEventArgs e)
        {
            if (_context.ShowAdvancedPasswordOptions)
                e.NewPage = "AdvancedPasswordOptionsPage";
            else
                e.NewPage = "PasswordPage";
        }
    }
}
